package com.myway.core.jersey.application;

import com.myway.core.jersey.exception.ExceptionMapperSupport;
import com.myway.core.jersey.filter.CORSRequestFilter;
import com.myway.core.jersey.gzip.GZIPWriterInterceptor;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;

/**
 * @ClassName: RestApplication <br/>
 * @Description: 注册资源的入口 <br/>
 * @CreateDate: 2016年4月27日 下午5:23:55 <br/>
 * @author Toby
 * @version V1.0
 */
public class RestApplication extends ResourceConfig {
	
	public RestApplication() {
		register(RequestContextFilter.class);
		// 注册日志打印
		register(LoggingFilter.class);
		// 注册json格式转换服务
		register(JacksonJsonProvider.class);
		// 注册请求过滤器
		register(CORSRequestFilter.class);
		// 注册拦截器，用于gzip压缩
		register(GZIPWriterInterceptor.class);
		// 异常拦截
		register(ExceptionMapperSupport.class);
		// 注册服务资源方式
		// register(SimpleResouce.class);
		packages("com.euair.rest");
	}
}
